package com.timoon.webcomponent.utility.common;

import org.apache.wicket.AttributeModifier;
import org.apache.wicket.Component;
import org.apache.wicket.markup.html.WebMarkupContainer;
import org.apache.wicket.markup.html.basic.Label;
import org.apache.wicket.markup.html.panel.EmptyPanel;
import org.apache.wicket.markup.html.panel.Panel;

import com.timoon.webcomponent.utility.product.BaseProductPanel;

/**
 *<p>bootstrap.tab，四个选项卡</p>
 *<p>需要四个标题，及对应的四个panel</p>
 *<p>Copyright:Copyright(c)2013</p>
 *<p>Company:timoon</p>
 *@author 付乐天
 *@version 1.0 */

public class HorizontalTab4Panel extends BaseProductPanel {

	private HorizontalTab4Parameter parameter;
	
	public HorizontalTab4Panel(String id,HorizontalTab4Parameter parameter) {
		super(id);
		// TODO Auto-generated constructor stub
		
		this.parameter=parameter;
		
		renderPanel();
	}

	private void renderPanel() {
		// TODO Auto-generated method stub
		renderTabs();
	}

	private void renderTabs() {
		// TODO Auto-generated method stub
		String[] labels=this.parameter.getLabels();
		Panel[] panels=this.parameter.getPanels();
		
		if(labels!=null&&labels.length==4){
		}else{
			throw new RuntimeException("labels必须为四个");
		}
		
		if(panels!=null&&panels.length==4){
			
		}else{
			throw new RuntimeException("panels必须为四个");
		}
		
		for(int i=1;i<=4;i++){
			String a="wk_a"+i;
			String div="wk_content"+i;
			Integer random=com.timoon.app.utils.GlobalRandom.getRandom();
			
			WebMarkupContainer alabel=new WebMarkupContainer(a);
			alabel.add(new AttributeModifier("href", "#linkto-"+random));
			add(alabel);
			
			Label label=new Label("wk_label"+i,labels[i-1]);
			alabel.add(label);
			
			WebMarkupContainer content=new WebMarkupContainer(div);
			content.add(new AttributeModifier("id", "linkto-"+random));
			add(content);
			content.add(panels[i-1]);
		}
	}

}
